#include "SceneBase.h"
#include "GLGlobalProtocol.h"

CSceneBase::CSceneBase(void) :
	m_Director(cocos2d::Director::getInstance()),
	m_SceneManager(CSceneManager::GetInstance()),
	m_LayerManager(CLayerManager::GetInstance()),
	m_LogicCache(CLogicCache::GetInstance()),
	m_LogicData(CLogicData::GetInstance()),
	m_UiManager(CCommonUiManager::GetInstance()),
	m_UiConfig(CUiConfig::GetInstance())
{

}


CSceneBase::~CSceneBase(void)
{
}

void CSceneBase::ReportError(uint32_t err) {
	if (err < CommonErrnoSucceed)
		return;

	m_Director->getScheduler()->performFunctionInCocosThread(CC_CALLBACK_0(CSceneBase::onReportError, this, m_LogicCache->GetError(err)));
}


void CSceneBase::ReplaceScene(CSceneManager::ChildIndex index) {
	m_Director->getScheduler()->performFunctionInCocosThread(CC_CALLBACK_0(CSceneBase::onReplaceScene, this, index));
}

void CSceneBase::onReportError(const std::string& err) {
	m_ReportErrFunc(err);
}

void CSceneBase::onReplaceScene(CSceneManager::ChildIndex index) {
	m_SceneManager->setCurrentScene(index);
}
